# coding=utf-8
from enum import Enum


class ChoicesEnum(Enum):

    @classmethod
    def choices(cls) -> list:
        return [(v.value, k) for k, v in cls._member_map_.items()]


class ReviewStatusEnum(ChoicesEnum):
    in_review = 0
    passed = 1
    rejected = 2
    ignored = 3
    deleted = 4

    inactive = 5  # 被封禁的用户新发帖子的状态

    @classmethod
    def visible_values(cls):
        return [cls.in_review.value, cls.passed.value]


class GenderEnum(ChoicesEnum):
    """
    用户性别
    """
    girl = 'g'
    boy = 'b'
    unknown = ''
    # girl = ('g', 'girl', '女')
    # boy = ('b', 'boy', '男')


in_review_channels = {
    'xiaomi': '9'
}


def is_in_review(request):
    if not request:
        return False
    channel = request.ua.other.channel
    if channel:
        return in_review_channels.get(request.ua.other.channel) == request.ua.other.build
    return False


def is_huawei_in_review(request):
    # if not request:
    #     return False
    # version = int(request.ua.other.build or 0)
    # # version in [4, 11, 12] and
    # if str(request.ua.other.channel) in ['huawei']:
    #     return True
    return False


BLACK_WORDS = ['性',
               '贱',
               '骚',
               '淫',
               '阴',
               '肛',
               '足交',
               '网调',
               '射',
               '微信',
               'qq',
               '操',
               '舔',
               '约炮',
               '鸡巴',
               '做爱',
               '奸',
               '逼',
               '奶子',
               '艹']

WHITE_WORDS = [
    '男性', '女性'
]


def check_black_words(content):
    white_content = content
    for x in WHITE_WORDS:
        white_content = white_content.replace(x, '')
    return [x for x in BLACK_WORDS if x in white_content]
